package router

import (
	utils "chat/util"
	"fmt"
	"github.com/gin-gonic/gin"
	"gorm.io/gorm"
	"net/http"
)

func CreateBaseRouter(db *gorm.DB) {
	g := gin.Default()
	var auth = utils.Claims{}
	g.MaxMultipartMemory = 40 << 20
	g.StaticFS("/static", http.Dir("static"))
	baseGroup := g.Group("/api/v1")
	{
		CreateLoginRouter(baseGroup.Group("/user"), db)
		CreateWSRouter(baseGroup.Group("/ws"), db)
		CreateMusicRouter(baseGroup.Group("/music", auth.Middleware()), db)
		CreateUpload(baseGroup.Group("/upload"))

	}
	err := g.Run(":9999")
	if err != nil {
		fmt.Println("run error", err)
		return
	}
}
